<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title></title>
    <link href="css/mui.min.css" rel="stylesheet"/>
    <style type="text/css">
    	body{
    		 background:url(img/bg.png);
    		 padding-bottom: 52px;
    		 position: absolute;
    		 width: 100%;
    		 min-height: 100%;
    	}
    	.mui-content.con{
				padding-left: 20px;
				padding-right: 20px;
				position: relative;
			}
			.banquan{
				margin-top: 220px;
				width:100%;
				text-align: center;
				font-size: 14px;
			}
			.mui-input-row{
				padding:5px 0;
			}
			.ball {
		    position: fixed;
		    z-index: 100;
		    line-height: 2.75rem;
		    width: 2.75rem;
		    height: 2.75rem;
		    padding: .5rem;
		    display: flex;
		    justify-content: center;
		    align-items: center;
		    border-radius: 99px;
		    font-size: 12px;
		    color: #fff;
		    /*border: 1rem solid transparent;*/
		    background-color: #ed424b;
		    background-clip: padding-box;
		    text-decoration: none;
		    top: 2em;
		}
		.mui-input-group .mui-input-row{
			margin-bottom: 5px;
			padding-bottom: 5px;
			min-height: 40px;
			height: auto;
		}
    </style>
    <script src="" type="text/javascript" charset="utf-8"></script>
    <script src="js/publicErr.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
	<div class="mui-content con" style="text-align: center">
		<ul class="mui-table-view" style="margin-top: 100px;margin-bottom: 50px;">
		    <li class="mui-table-view-cell mui-media">
		        <a href="javascript:;" style="display: flex;justify-content: flex-start;align-items: center;">
		            <img class="mui-media-object mui-pull-left" id="user_img" src="img/index.jpg">
		            <div style="font-size: 16px;font-weight: 600;" id="user_name">
		                	用户昵称昵称昵称
		            </div>
		        </a>
		    </li>
		</ul>
		<form class="mui-input-group" style="padding-top: 5px;">
		    <div class="mui-input-row" >
		        <label>过关数:</label>
		    	<input type="number" id="pass" class="mui-input-clear" placeholder="请输入过关数">
		    </div>
		    <div class="mui-input-row">
		        <label>总用时(H)：</label>
		        <input type="number" id="allTime" class="mui-input-clear" placeholder="请输入总用时(小时)">
		    </div>
		    <div class="mui-button-row">
		        <button id="submit" type="button" class="mui-btn mui-btn-primary" >确认</button>
		    </div>
		</form>
		<div id="nav" onclick="onAgain()" class="ball">返回</div>
	</div>
	<p class="banquan">版权所有©上海永乐数码科技公司<br/>沪ICP备10202509号-2</p>
</body>
<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/mui.min.js"></script>
<script src="js/urlfun.js" type="text/javascript" charset="utf-8"></script>
<script src="js/Inertia.js" type="text/javascript" charset="utf-8"></script>
<script src="js/request.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">	
			//滑动的小球
			new Inertia(document.getElementById('nav'));
			
			(function($, doc) {
				$.init({});
				$.plusReady(function() {
					did = plus.device.uuid.toString();
				})
				//初始化用户昵称和id
				var allData = JSON.parse(localStorage.getItem("info")).data;
				var user_img = document.getElementById("user_img");
				var user_name = document.getElementById("user_name");
				var imgurl = allData.user.headimg_url || "./img/emity.jpg";
				user_img.setAttribute("src",imgurl);
				user_name.innerText = allData.user.nick_name;
				//设置事件监听
				var btn = document.getElementById("submit");
				btn.addEventListener("click", pushAuth, false);
				function pushAuth(el) {
					el.stopPropagation();
					var passNum = document.getElementById("pass").value;
					var allTime = document.getElementById("allTime").value;
					var data = {
						open_id:allData.user.open_id,
						pass_count:parseInt(passNum),
						game_time:parseFloat(allTime),
					}
					request.requestAjax("post","game/save",data,function(res){
						console.log(JSON.stringify(res))
						if(res.state == true){
							plus.nativeUI.toast('添加成功！');
							localStorage.clear();
							mui.openWindow({
								url: "auth.html",
								id: "auth.html",
								createNew:true,
							})
						}
						if(res.code){
							alert(res.error);
							mui.openWindow({
								url: "auth.html",
								id: "auth.html",
								createNew:true,
							})
						}
					},function(res){
						console.log(JSON.stringify(res))
						alert("网络错误")
					})
				}
			var backButtonPress = 0;
			mui.oldback = mui.back;
			mui.back = function(event) {
						backButtonPress++;
						if (backButtonPress > 1) {
							plus.runtime.quit();
						} else {
							plus.nativeUI.toast('再按一次退出应用');
						}
						setTimeout(function() {
							backButtonPress = 0;
						}, 1000);
					
					return false;
				};
				
			}(mui, document));
			function onAgain() {
				localStorage.clear();
				mui.openWindow({
					url: "auth.html",
					id: "auth.html",
					createNew:true,
				})
			}
		
</script>
</html>